import urllib.parse as up
import urllib.request as ur
import json

while True:
    word = input('输入要翻译的内容')
    data = {'kw': word}

    data_url = up.urlencode(data)

    requset = ur.Request(
        url='https://fanyi.baidu.com/sug',
        data = data_url.encode('utf-8')
    )

    response = ur.urlopen(requset).read()



    ret = json.loads(response)

    fanyi = ret['data'][0]['v']


    print(fanyi)